// /////////////////////////////////////////////////////////////////////////////
//
// Name:            CameraPanel.cpp
// Author:          Michael Bartsch
//
// Desc :           This file contains the CCameraPanel class. This panel
//                  displays the newest image taken by the camera.
//
// License:         Copyright (C) 2008-2009 Michael Bartsch
//
//                  This program is free software: you can redistribute it
//                  and/or modify it under the terms of the GNU General Public
//                  License as published by the Free Software Foundation,
//                  either version 3 of the License, or (at your option) any
//                  later version.
//
//                  This program is distributed in the hope that it will be
//                  useful, but WITHOUT ANY WARRANTY; without even the implied
//                  warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
//                  PURPOSE. See the GNU General Public License for more
//                  details.
//
//                  You should have received a copy of the GNU General Public
//                  License along with this program. If not, see
//                  <http://www.gnu.org/licenses/>.
//
// /////////////////////////////////////////////////////////////////////////////

// Include required header file(s).
#include "CameraPanel.h"


// CCameraPanel Events. - [ BEGIN ]
BEGIN_EVENT_TABLE(CCameraPanel, wxPanel)
   EVT_PAINT(CCameraPanel::onPaint)
END_EVENT_TABLE()
// CCameraPanel Events. - [ END ]


// CCameraPanel.
// Constructor.
CCameraPanel::CCameraPanel(wxWindow *parent)
: wxPanel(parent, wxID_ANY, wxDefaultPosition, wxSize(385, 288))
{
    pColourAnalyser = CColourAnalyser::Instance();
}

// Event Functions. - [ BEGIN ]
void CCameraPanel::onPaint(wxPaintEvent &event)
{
    // Here we're going to create the paint DC.
    wxBufferedPaintDC *PanelDC = new wxBufferedPaintDC(this);

    // Paint on the DC.
    PanelDC->SetBrush(wxBrush(wxT("black"), wxSOLID));
    PanelDC->DrawRectangle(0, 0, 385, 288);

    if(pColourAnalyser->getCameraBitmap() != NULL)
      PanelDC->DrawBitmap(*pColourAnalyser->getCameraBitmap(), 16, 0, false);

    // Tidy code up.
    delete PanelDC;
}
// Event Functions. - [ END ]

// End of File
